﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddProduct.aspx.cs" Inherits="ShowroomMobile.AddProduct" Theme="tbmobile"
  %>

<%@ Register Assembly="ShowroomMobile" Namespace="jNET.Controls" TagPrefix="cc" %>
<%@ Register Src="~/Controls/DataPagerCtrl.ascx" TagName="DataPager" TagPrefix="uc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="css/admin.css" rel="stylesheet" type="text/css" />
    <link href="css/CustomGrid.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="scripts/jquery.js"></script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel runat="server" ID="upAddProduct">
        <ContentTemplate>
            <div>
                <script type="text/javascript">
                    function SelectAll() {
                        if ($("#ckbSelectAll").is(':checked')) {
                            $(".ckbSelect").attr("checked", true);
                            $(".ckbSelect").each(function () {
                                Select(this);
                            });
                        }
                        else {
                            $(".ckbSelect").removeAttr("checked");
                        }
                    }
                    function Select(ckb) {
                        var hidSelectedProductID = document.getElementById("<%= hidSelectedProductID.ClientID %>");
                        if (ckb.checked) {
                            hidSelectedProductID.value += "," + $(ckb).attr("value") + ",";
                        }
                        else {
                            hidSelectedProductID.value = hidSelectedProductID.value.replace("," + $(ckb).attr("value") + ",", "");
                        }
                    }
                </script>
                <asp:HiddenField runat="server" ID="hidSelectedProductID" />
                <asp:Panel runat="server" DefaultButton="btnSearchProduct" style="padding:5px 0px 5px 0px;">
                    <asp:TextBox runat="server" ID="txtSearchProduct" placeholder="Search" Width="200px" class="txt" />&nbsp;<asp:Button 
                        runat="server" ID="btnSearchProduct" Text="Search" 
                        onclick="btnSearchProduct_Click" />
                </asp:Panel>
                <div style="height:370px;overflow-y:auto;">
                <cc:CustomGrid Width="100%" AllowRowSelect="false" GridLines="None" CssClass="clientGrid"
                    ID="gridProducts" runat="server" AutoGenerateColumns="false" DataKeyField="ID" 
                        AllowCustomPaging="true" PageSize="5" AllowPaging="true" PagerStyle-Mode="NumericPages"
                    OnNeedDataSource="gridProducts_OnNeedDataSource" 
                        onpageindexchanged="gridProducts_PageIndexChanged">
                    <Columns>
                        <cc:CustomTemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                            ItemStyle-Width="10px" HeaderStyle-Width="10px" HeaderText="">
                            <ItemTemplate>
                                <input type="checkbox" class="ckbSelect" value='<%# Eval("ID") %>' onchange="Select(this);" />
                            </ItemTemplate>
                            <HeaderTemplate>
                                <input type="checkbox" id="ckbSelectAll" onchange="SelectAll();" />
                            </HeaderTemplate>
                        </cc:CustomTemplateField>
                        <cc:CustomTemplateField UniqueName="ImageUrl" HeaderText="Image" ItemStyle-Width="120px"
                            ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <img src='<%# ShowroomMobile.Utilities.GetKeySetting("PathUploadImageThumb") + "/" + Eval("ImageUrl") %>'
                                    class="imgAdmin" />
                            </ItemTemplate>
                        </cc:CustomTemplateField>
                        <cc:CustomTemplateField HeaderText="Name" ItemStyle-Width="30%" HeaderStyle-Width="30%">
                            <ItemTemplate>
                                    <%# Eval("Name").ToString() %>
                            </ItemTemplate>
                        </cc:CustomTemplateField>
                        <cc:CustomTemplateField HeaderText="Description" ItemStyle-Width="60%" HeaderStyle-Width="60%">
                            <ItemTemplate>
                                <%# ShowroomMobile.Utilities.GetSubString(Eval("Description").ToString(), 200)%>
                            </ItemTemplate>
                        </cc:CustomTemplateField>
                    </Columns>
                </cc:CustomGrid>
                </div>
                <div align="center" style="padding:5px">
                <asp:Button runat="server" ID="btnAddSelectedProduct" OnClick="btnAddSelectedProduct_Click"
                    Text="Add Selected Items" /></div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
